AM_CPPFLAGS = $(SLGLADE_CFLAGS) -I$(SLANG_INC) \
              -DSLGLADE_DOC_DIR=\"$(prefix)/doc/slglade\"

## Specify installation dir for S-Lang modules
slmodexecdir = $(libdir)/slang/modules

if APPLE
## On Darwin-based systems (or at least Mac OS X), the SLgtk module
## is a static library, so we can't link against it.  However, we
## still need symbols from it, so don't specify -no-undefined.
glade_link_flags = -R $(SLANG_LIB) -L$(SLANG_LIB) \
		   -lslang $(SLGLADE_LIBS)
else
glade_link_flags = -no-undefined \
		   -R $(SLANG_LIB) -R $(SLGTK_MOD) \
		   -L$(SLANG_LIB) -L$(SLGTK_MOD) \
		   -lslang -lslgtk $(SLGLADE_LIBS)
endif

slmodexec_LTLIBRARIES = glade-module.la
glade_module_la_SOURCES = glade-module.c
glade_module_la_LDFLAGS = -module -avoid-version $(glade_link_flags)

## To run after all other installation commands:  If libtool named the shared
## object something other than "glade-module.so" (which S-Lang will look
## for), create a symbolic link with that name to the shared object

install-exec-hook:
	@if test ! -f $(slmodexecdir)/glade-module.so; then \
	  echo "Creating glade-module.so symbolic link"; \
	  $(LN_S) \
	    `grep 'dlname=' $(slmodexecdir)/glade-module.la | $(AWK) -F\' '{ print $$2 }'` \
	    $(slmodexecdir)/glade-module.so; \
	fi

## Apparently the version of automake I'm using doesn't support this, but
## I'll leave it here for the future

uninstall-hook:
	rm -f $(slmodexecdir)/glade-module.so

